﻿<%@ Page Title="" Language="C#" MasterPageFile="~/master/customer.master" AutoEventWireup="true"
    CodeBehind="search_trains.aspx.cs" Inherits="RailwayReservationWeb.search_trains" %>

<asp:Content ID="Content2" ContentPlaceHolderID="PathContent" runat="server">
    <ol class="breadcrumb">
        <li><a href="default.aspx">Home</a></li>
        <li><a href="#">Booking</a></li>
        <li class="active"><a href="search_trains.aspx">Availability</a></li>
    </ol>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <div class="page-header">
        <h1>
            Trains Availability</h1>
    </div>
    <p id="pMessage" runat="server" class="alert alert-danger">
    </p>
    <asp:ValidationSummary ID="ValidationSummary1" runat="server" CssClass="alert alert-danger"
        DisplayMode="List" />
    <div class="form-horizontal">
        <div class="form-group">
            <div class="col-md-3">
                <asp:Label ID="Label4" runat="server" Text="Origin" AssociatedControlID="cboOrigin"
                    CssClass="control-label"></asp:Label>
            </div>
            <div class="col-md-9">
                <asp:DropDownList ID="cboOrigin" runat="server" CssClass="form-control">
                </asp:DropDownList>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-3">
                <asp:Label ID="Label5" runat="server" Text="Destination" AssociatedControlID="cboDestination"
                    CssClass="control-label"></asp:Label>
            </div>
            <div class="col-md-9">
                <asp:DropDownList ID="cboDestination" runat="server" CssClass="form-control">
                </asp:DropDownList>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-3">
                <asp:Label ID="Label2" runat="server" Text="Journey Date" AssociatedControlID="txtJrnDate"
                    CssClass="control-label"></asp:Label>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="Please input Journey Date"
                    ForeColor="Red" ControlToValidate="txtJrnDate">∗</asp:RequiredFieldValidator>
            </div>
            <div class="col-md-9">
                <asp:TextBox ID="txtJrnDate" runat="server" CssClass="form-control"></asp:TextBox>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-offset-3 col-md-9">
                <asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="btn btn-default"
                    OnClick="btnSearch_Click" />
            </div>
        </div>
    </div>
    <asp:GridView ID="gvwSchedule" runat="server" AllowPaging="True" Width="100%" CssClass="table table-condensed table-bordered table-striped table-hover"
        AutoGenerateColumns="False" Style="font-size: 95%" AllowSorting="True" 
        onrowcommand="gvwSchedule_RowCommand">
        <PagerStyle CssClass="pagerArea" Wrap="True" />
        <PagerTemplate>
            <asp:GridPager ID="GridViewPager1" runat="server" ShowFirstAndLast="True" ShowNextAndPrevious="True"
                PageLinksToShow="10" NextText="&rsaquo;" PreviousText="&lsaquo;" FirstText="&laquo;"
                LastText="&raquo;" />
        </PagerTemplate>
        <Columns>
            <asp:BoundField DataField="ScheduleId" HeaderText="Id" ReadOnly="True" SortExpression="ScheduleId" />
            <asp:BoundField DataField="Train.TrainName" HeaderText="Train Name" SortExpression="Train.TrainName">
            </asp:BoundField>
            <asp:BoundField DataField="Station.StationName" HeaderText="Origin" SortExpression="Station.StationName">
            </asp:BoundField>
            <asp:BoundField DataField="DepTime" HeaderText="Dep Time" ReadOnly="True" SortExpression="DepTime" />
            <asp:BoundField DataField="Station1.StationName" HeaderText="Destination" SortExpression="Station1.StationName">
            </asp:BoundField>
            <asp:BoundField DataField="ArrTime" HeaderText="Arr Time" ReadOnly="True" SortExpression="ArrTime" />
            <asp:BoundField DataField="TravelTime" HeaderText="Travel Time" ReadOnly="True" SortExpression="TravelTime" />
            <asp:TemplateField HeaderText="Days Of Run" SortExpression="RunDays">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# FormatRunDays((String)Eval("RunDays")) %>'
                        CssClass="run-days"></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                        Text="Update"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                        Text="Cancel"></asp:LinkButton>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Booking"
                        CommandArgument='<%# Bind("ScheduleId") %>' Text="Book Now"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <EmptyDataTemplate>
            There are currently no items in this table.
        </EmptyDataTemplate>
    </asp:GridView>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="SideContent" runat="server">
</asp:Content>
<asp:Content ID="Content5" runat="server" ContentPlaceHolderID="EndContent">
    <script src='<%= ResolveClientUrl("~/js/bootstrap-datepicker.js") %>' type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#MainContent_txtJrnDate').datepicker();
        });
    </script>
</asp:Content>
